$(function () {
  /* 1.登录功能
     1.1 获取输入框账号和密码
     1.2 非空判断
     1.3 ajax发送请求
     1.4 服务器响应之后跳转首页
  */
  $('.input_sub').click(function (e) {
    e.preventDefault()
    let username = $('.input_txt').val()
    let password = $('.input_pass').val()
    // 非空判断
    if (username.length == 0 || password.length == 0) {
      // alert('请输入用户名和密码')
      $('.modal-body>p').text('请输入用户名和密码')

      $('#myModal').modal()
      return
    }
    $.ajax({
      url: BigNew.user_login,
      type: 'post',
      dataType: 'json',
      data: {
        // username: username,
        // password: password
        username,
        password
      },
      success: function (backData) {
        console.log(backData);
        // alert(backData.msg)
        if (backData.code == 200) {
          $('.modal-body>p').text(backData.msg)

          $('#myModal').modal()

          $('#myModal').on('hidden.bs.modal', function (e) {
            localStorage.setItem('token', backData.token)
            window.location.href = './index.html'
          })

        } else {
          $('.modal-body>p').text(backData.msg)

          $('#myModal').modal()
        }


      }
    });


  })
})